Technology Tales

Adventures & experiences in contemporary technology

Running cron jobs using the www-data system account

22nd December 2018

When you set up your own web server or use a private server (virtual or physical), you will find that web servers run using the www-data account. That means that website files need to be accessible to that system account if not owned by it. The latter is mandatory if you you want WordPress to be able to update itself with needing FTP details.

It also means that you probably need scheduled jobs to be executed using the privileges possess by the www-data account. For instance, I use WP-CLI to automate spam removal and updates to plugins, themes and WordPress itself. Spam removal can be done without the www-data account but the updates need file access and cannot be completed without this. Therefore, I got interested in setting up cron jobs to run under that account and the following command helps to address this:

sudo -u www-data crontab -e

For that to work, your own account needs to be listed in /etc/sudoers or be assigned to the sudo group in /etc/group. If it is either of those, then entering your own password will open the cron file for www-data and it can be edited as for any other account. Closing and saving the session will update cron with the new job details.

In fact, the same approach can be taken for a variety of commands where files only can be access using www-data. This includes copying, pasting and deleting files as well as executing WP-CLI commands. The latter issues a striking message if you run a command using the root account, a pervasive temptation given what it allows. Any alternative to the latter has to be better from a security standpoint.

Piggybacking an Android Wi-Fi device off your Windows PC’s internet connection

16th March 2013

One of the disadvantages of my Google/Asus Nexus 7 is that it needs a Wi-Fi connection to use. Most of the time this is not a problem since I also have a Huawei mobile WiFi hub from T-Mobile and this seems to work just about anywhere in the U.K. Away from the U.K. though, it won’t work because roaming is not switched on for it and that may be no bad thing with the fees that could introduce. My HTC Desire S could deputise but I need to watch costs with that too.

There’s also the factor of download caps and those apply both to the Huawei and to the HTC. Recently, I added Anquet‘s Outdoor Map Navigator (OMN) to my Nexus 7 through the Google Play store for a fee of £7 and that allows access to any walking maps that I have bought from Anquet. However, those are large downloads so the caps start to come into play. Frugality would help but I began to look at other possibilities that make use of a laptop’s Wi-Fi functionality.

Looking on the web, I found two options for this that work on Windows 7 (8 should be OK too): Connectify Hotspot and Virtual Router Manager. The first of these is commercial software but there is a Lite edition for those wanting to try it out; that it is not a time limited demo is not something that I can confirm though that did not seem to be the case since it looked as if only features were missing from it that you’d get if you paid for the Pro variant. The second option is an open source one and is free of charge apart from an invitation to donate to the project.

Though online tutorials show the usage of either of these to be straightforward, my experiences were not all that positive at the outset. In fact, there was something that I needed to do and that is why this post has come to exist at all. That happened even after the restart that Conectify Hotspot needed as part of its installation; it runs as a system service so that’s why the restart was needed. In fact, it was Virtual Router Manager that told me what the issue was and it needed no reboot. Neither did it cause network disconnection of a laptop like the Connectify offering did on me and that was the cause of its ejection from that system; limitations in favour of its paid addition aside, it may have the snazzier interface but I’ll take effective simplicity any day.

Using Virtual Router Manager turns out to be simple enough. It needs a network name (also known as an SSID), a password to restrict who accesses the network and the internet connection to be shared. In my case, the was Local Area Connection on the drop down list. With all the required information entered,  I was ready to start the router using the Start Network Router button. The text on this changes to Stop Network Router when the hub is operational or at least it should have done for me on the first time that I ran it. What I got instead was the following message:

The group or resource is not in the correct state to perform the requested operation.

The above may not say all that much but it becomes more than ample information if you enter it into the likes of Google. Behind the scenes, Virtual Router Manager is using native Windows functionality is create a WiFi hub from a PC and it appears to be the Microsoft Virtual Wi-Fi Miniport Adapter from what I have seen. When I tried setting up an adhoc Wi-Fi network from a laptop to the Nexus 7 using Windows’ own network set up capability via its Control Panel, it didn’t do what I needed so there might be something that third party software can do. So, the interesting thing about the solution to my Virtual Router Manager problem was that it needed me to delve into the innards of Windows a little.

Firstly, there’s running Command Prompt (All Programs > Accessories) from the Start Menu with Administrator privileges. It helps here if the account with which you log into Windows is in the Administrators group since all you have  to do then is right click on the Start Menu entry and choose Run as administrator entry in the pop-up context menu. With a command line window now open, you then need to issue the following command:

netsh wlan set hostednetwork mode=allow ssid=[network name] key=[password] keyUsage=persistent

When that had done its thing, Virtual Router Manager worked without a hitch though it did turn itself after a while and that may be no bad thing from the security standpoint. On the Android side, it was a matter of going in Settings > Wi-Fi and choose the new network that have been creating on the laptop. This sort of thing may apply to other types of tablet (Dare I mention iPads?) so you could connect anything to the hub without needing to do any more on the Windows side.

For those wanting to know what’s going on behind the scenes on Windows, there’s a useful tutorial on Instructables that shows what third party software is saving you from having to do. Even if I never go down the more DIY route, I probably have saved myself having to buy a mobile Wi-Fi hub for any trips to Éire. For now, the Irish 3G dongle that I already have should be enough.

Uses for symbolic links

24th April 2007

UNIX (and Linux) does a wonderful trick with its file and folder shortcuts; it effectively treats them as file and folder transporters that transfer associate a file or folder that exists in one folder hierarchy with another and it is treated as if it exists in that hierarchy too. For example, the images folder under /www/htdocs/blog can have a link under /www/htdocs/ that makes it appear that its contents exist in both places without any file duplication. For instance, the pwd command cannot tell a folder from a folder shortcut. To achieve this, I use what are called symbolic links and the following command achieves the outcome in the example:

ln -s /www/htdocs/blog/images /www/htdocs/images

The first file path is the destination for the link while the second one is that for the link itself. I had a problem with Google Reader not showing up images in its feed displays so symbolic links rode to the rescue as they did for resolve a similar conundrum that I was encountering when editing posts in my hillwalking blog.

Online learning

18th April 2021

Recently, I shared my thoughts on learning new computing languages by oneself using books, online research and personal practice. As successful as that can be, there remains a place for getting some actual instruction as well. Maybe that is why so many turn to YouTube, where there is a multitude of video channels offering such possibilities without cost. What I have also discovered is that this is complemented by a host of other providers whose services attract a fee, and there will be a few of those mentioned later in this post. Paying for online courses does mean that you can get the benefit of curation and an added assurance of quality in what appears to be a growing market.

The variation in quality can dog the YouTube approach, and it also can be tricky to find something good, even if the platform does suggest new videos based on what you have been watching. Much of what is found there does take the form of webinars from the likes of the Why R? Foundation, Posit or the NHSR Community. These can be useful, and there are shorter videos from such providers as the Association of Computing Machinery or SAS Users. These do help more if you already have some knowledge about the topic area being discussed, so they may not make the best starting points for someone who is starting from scratch.

Of course, working your way through a good book will help, and it is something that I have been known to do, but supplementing this with one or more video courses really adds to the experience and I have done a few of these on LinkedIn. That part of the professional platform came from the acquisition of Lynda.com and the topic areas range from soft skills like time management through to computing skills courses with R, SAS and Python seeing coverage among the data science portfolio. Even O’Reilly has ventured into the area in an expansion from the book publishing activities for which so many of us know the organisation.

The available online instructor community does not stop at the above since there are others like Degreed, Baeldung, Udacity, Programiz, Udemy, Business Science and Datanovia. Some of these tend towards online education provision that feels more like an online university course and those are numerous as well as you will find through Data Science Central or KDNuggets. Both of these earn income from advertising to pay for featured blog posts and newsletters, while the former also organises regular webinars and was my first port of call when I became curious about the world of data science during the autumn of 2017.

My point of approach into the world of online training has been as a freelance information professional needing to keep up to date with a rapidly changing field. The mix of content that is both free of charge and that which attracts a fee is one that can work. Both kinds do complement each other while possessing their unique advantages and disadvantages. The need to continually expand skills and knowledge never goes away, so it is well worth spending some time working what you are after, since you need to be sure that any training always adds to your own knowledge and skill level.

Work locally, update remotely

4th December 2008

Here’s a trick that might have its uses: using a local WordPress instance to update your online blog (yes, there are plenty of applications that promise to edit your online blog but these need file permissions to the likes of xmlrpc.php to be opened up). Along with the right database access credentials and the ability to log in remotely, adding the following two lines to wp-config.php does the trick:

define('WP_SITEURL', 'http://localhost/blog');

define('WP_HOME', 'http://localhost/blog');

These two constants override what is in the database and allow to update the online database from your own PC using WordPress running on a local web server (Apache or otherwise). One thing to remember here is that both online and offline directory structures are similar. For example, if your online WordPress files are in blog in the root of the online web server file system (typically htdocs for Linux), then they need to be contained in the same directory in the root of the offline server too. Otherwise, things could get confusing and perhaps messy. Another thing to consider is that you are modifying your online blog so the usual rules about care and attention apply, particularly with respect to using the same version of WordPress both locally and remotely. This is especially a concern if you, like me, run development versions of WordPress to see if there are any upheavals ahead of us like the overhaul that is coming in with WordPress 2.7.

An alternative use of this same trick is to keep a local copy of your online database in case of any problems while using a local WordPress instance to work with it. I used to have to edit the database backup directly (on my main Ubuntu system), first with GEdit but then using a sed command like the following:

sed -e s/www\.onlinewebsite\.com/localhost/g backup.sql > backup_l.sql

The -e switch uses regular expression substitution that follows it to edit the input with the output being directed to a new file. It’s slicker than the interactive GEdit route but has been made redundant by defining constants for a local WordPress installation as described above.

Relocating the Apache web server document root directory in Fedora 12

9th April 2010

So as not to deface anything that is available online on the web, I have a tendency to set up an offline Apache server on a home PC to do any tinkering away from the eyes of the unsuspecting public. Though Ubuntu is my mainstay for home computing, I do have a PC with Fedora installed and I have been trying to get an Apache instance starting automatically on there without success for a few months. While I can start it by running the following command as root, I’d rather not have more manual steps than is necessary.

httpd -k start

The command used by the system when it starts is different and, even when manually run as root, it failed with messages saying that it couldn’t find the directory while the web server files are stored. Here it is:

service httpd start

The default document root location on any Linux distribution that I have seen is /var/www and all is very well with this but it isn’t a safe place to leave things if ever a re-installation is needed. Having needed to wipe /var after having it on a separate disk or partition for the sake of one installation, it doesn’t look so persistent to me. In contrast, you can safeguard /home by having it on another disk or in a dedicated partition and it can be retained even when you change the distro that you’re using. Thus, I have got into the habit of having the root of the web server document root folder in my home area and that is where I have been seeing the problem.

Because of the access message, I tried using chmod and chgrp but to no avail. The remedy has to do with reassigning the security contexts used by SELinux. In Fedora, Apache will not work with the context user_home_t that is usually associated with home directories but needs httpd_sys_content_t instead. To find out what contexts are associated with particular folders, issue the following command:

ls -Z

The final solution was to create a user account whose home directory hosts the root of the web server file system, called www in my case. Then, I executed the following command as root to get things going:

chcon -R -h -t httpd_sys_content_t /home/www

It seems that even the root of the home directory has to have an appropriate security context (/home has home_root_t so that might do the needful too). Without that, nothing will work even if all is well at the next level down. The switches for chcon command translate as follows:

-R : recursive; applies changes to all files and folders within a directory.

-h : changes apply only to symbolic links and not to where they refer in the file system.

-t : alters context type.

It took a while for all of this stuff about SELinux security contexts to percolate through to the point where I was able to solve the problem. A spot of further inspiration was needed too and even guided my search for the information that I needed. It’s well worth trying Linux Home Networking if you need more information. There are references to an earlier release of Fedora but the content still applies to later versions of Fedora right up to the current release if my experience is typical.

VMware Workstation in full screen mode hobbles my keyboard

14th May 2008

I have recently encountered an odd situation following my recent upgrade to Ubuntu 8.04: when I use VMware Workstation to run Windows XP in full screen mode, the keyboard no longer acts as it should. For instance, Caps Lock and Num Lock keys stop working as does the Shift key. Logging out and back in again is the least that’s needed to set things right but there has to be a better way to fix the problem. I am not saying that it’s limited to the scenario where I saw it happen but it’s still very odd behaviour. If you have a solution, please let me know. Of course, I’ll keep you posted if I find one. In the meantime, I’ll be avoiding full screen mode with VMware as much as I can.

Update 1:

I have done a spot of digging on this one since and gained the impression that there might be a conflict between VMware and the version of X.org Server that comes with Ubuntu. A restorative trick that I have seen suggested is to issue the following command in a terminal, replacing "gb" with your own locale, but I have yet to see if it works:

setxkbmap -rules xorg -layout "gb"

In any case, it looks as if it is not a permanent fix but just a way to keep working without resorting to system restarts, logging off and back on, etc.

Update 2:

I can now verify that the comand quoted above works for me. Of course, it would better to find a permanent fix and even better for the behaviour never to occur at all but any fix is better than none whatsoever.

Tidying dynamic URL’s

15th June 2007

A few years back, I came across a very nice article discussing how you would make a dynamic URL more palatable to a search engine and I made good use of its content for my online photo gallery. The premise was that URL’s that look like that below are no help to search engines indexing a website. Though this is received wisdom in some quarters, it doesn’t seem to have done much to stall the rise of WordPress as a blogging platform.

http://www.mywebsite.com/serversidescript.php?id=394

That said, WordPress does offer a friendlier URL display option too and you can see this in use on this blog; they look a little like the example URL that you see below, and the approach is equally valid for both Perl and PHP. I have been using the same approach for the Perl scripts powering my online phone gallery and now want to apply the same thinking to a gallery written in PHP:

http://www.mywebsite.com/serversidescript.pl/id/394

The way that both expressions work is that a web server will chop pieces from a URL until it reaches a physical file. For a query URL, the extra information after the question mark is retained in its QUERY_STRING variable while extraneous directory path information is passed in the variable PATH_INFO. For both Perl and PHP, these are extracted from the entries in an array; for Perl, this array is called is $ENV and $_SERVER is the PHP equivalent. Thus, $ENV{QUERY_STRING} and $_SERVER{‘QUERY_STRING’} traps what comes after the “?” while $ENV{PATH_INFO} and $_SERVER{‘PATH_INFO’} picks up the extra information following the file name (the “/id/394/” in the example). From there on, the usual rules apply regarding cleaning of any input but changing from one to another should be too arduous.

Buying OEM Vista?

27th January 2007

A few days ago, I mused over buying OEM Vista if/when the time came for me to do upgrade. Then, I came to the conclusion that OEM was a no-no unless you bought it installed on a system. In an article on the PC Magazine website, things seem not to be as cut and dried as that. Apparently, the perceived wisdom is that if you are building a system for yourself and you agree to provide all support as the system builder to yourself as the system user, then everything is OK under the licence. Also, there seems to be a trend among resellers that it is not them who are subject to the terms of the licence but the customers who purchase the OEM software. It is all just a little bit confusing. Draw your own conclusions…

Assorted Desktop Packages

29th September 2012

Here is some desktop software that is either commonplace in the world of Linux or needs a bit more publicity, at least in my opinion. The list is sorted alphabetically, in case you are left wondering at its first entry. As with everything in this place, it may grow or contract, but change certainly is a feature of the world of Linux anyway. That’s never a bad thing, even if it upsets some from time to time.

Calligra

This suite comes from the KDE project and includes office and graphical software. The latter includes Krita, which is described separately below, so this is an interesting collection of software.

Choqok

Linux does have a choice of Twitter/X clients and this is one of them. It’s a KDE application that also supports Pump.IO, GNU Social and Friendica instances. There are others on the support list too, though Mastodon is a surprising absence given the recent furore surrounding Twitter/X.

Darktable

The name is a play on that of Adobe’s Lightroom, and that gives you an idea of what it is about. This too allows non-destructive editing of images with the added information being kept in associated files with XMP extensions, one for each image. What the software does not have though is an image management interface like that of Lightroom or digiKam.

digiKam

This is more than an organiser, and may be the KDE project’s counterpart to Adobe’s closed source Lightroom. Its photo organising doesn’t mean automated folder creation from EXIF information like F-Spot, Shotwell or Rapid Photo Downloader. It is for that reason that I combine digiKam with the last entry on the preceding list, since I jumped ship from Shotwell. The image processing part of the application is something that I have to explore.

Eclipse

Other IDE’s have taken over me these days, but this had a use for editing PHP scripts once upon a time. It is better known for what it offers Java developers, though.

Emacs

A long-standing UNIX/Linux text editor that has been doing battle with Vi for longer than many can remember. Like the alternative, it has keyboard shortcuts that do anything but make concessions to Windows conventions, add needless steepening of any learning curve unless you find the appropriate option (CUA) that allows for some emulation of mainstream keyboard shortcuts. Nevertheless, there also is a GUI variant that makes life easier, and I have to concede that it has a history that is longer than even Microsoft itself. As if that weren’t enough compensation, it is a powerful piece of software whose functionality goes much further than text editing, whose surface I have only barely begun to scratch. The logic of the interface may differ from that to which many are accustomed, but it is consistent and well-thought-out nonetheless.

F-Spot

For a while, this was my photo organiser of choice, but it has not seen a new release since December 2010. Maybe that’s because it works well enough as it is, yet you cannot help thinking that a project with no new releases is a dead one, even if that sometime reflects how right they got things at the time.

FileZilla

Before my quest for added automation took over, this was my FTP client of choice, and its advent has made the need to buy such software extinct. That it works on both Windows and Linux is a bonus.

GIMP

The ubiquitous Photoshop challenger is maturing nicely, though its interface may not please some.

GraphicsMagick

This is very like ImageMagick (see below) with its main selling point being that it’s faster than its parent for the purpose of command line image editing; my own testing seems to support this so far. The commands that you use are similar to ImageMagick too, apart mainly from adding the gm command before the likes of convert and others. Speaking of convert, the GraphicsMagick version has yet to support the -annotate switch, so -draw needs to be used in its place.

ImageMagick

Using a command line tool for image processing may seem counter-intuitive, but there are operations where you need not have much user intervention. Included among these is image resizing and conversion between file formats, and yours truly has done both. Processing many files at a stroke comes naturally to this very useful and talented piece of software, too.

KODI

Software media centres lie largely beyond my purview, but this seems to be one of the better known of the breed. It overlays the desktop when it is running and caters for consumption of music, movies, TV, photo slideshows and games. Controversially, there even is PVR capability for recording live broadcasts as well.

Krita

For those with a more artistic bent, this is a digital drawing and illustration package that will work not only on Linux but also on Windows or OS X. The results can be striking, so it looks as if your talent may be the only limitation with this tool.

LibreOffice

Oracle’s takeover of Sun Microsystems meant that some feathers were ruffled in the open-source and free software community, and one example of a change coming from this is the forking of OpenOffice. It is that act that has brought LibreOffice into being, and it then gained so much ground that it eclipsed its parent.

LibreWolf

Mozilla may promote their wares as bing privacy-friendly, yet others are not sure, so Firefox has been forked to give LibreWolf. This removes telemetry, adds a content blocker along with other enhancements.

Mozilla Firefox

There’s no way that I could not include what once was the de facto standard web browser for Linux, though there’s competition from Chrome/Chromium now too. There is also a mobile version for phones running the Android OS.

Mozilla SeaMonkey

The original Mozilla suite still lives on, and this is what it’s called nowadays.

Mozilla Thunderbird

This has replaced Evolution on Linux systems that I use, and it comes close to eclipsing Microsoft Outlook everywhere else, too.

MythTV

The main function of this piece of software is to record broadcast TV, hence that part of the name. It also has media playback capability, and that is what makes it more of a media centre than the digital video recording functionality may suggest.

NEdit

UNIX/Linux offers plenty of text editors, so here’s another of the less well-known ones that I have encountered. Syntax highlighting is part of the offer and some menu customisation is possible too. In essence, it is a straightforward text editor that works with Windows keyboard shortcuts, but that can be no bad thing.

NetBeans

You cannot feature Eclipse in a software listing without having NetBeans too. In fact, it was NetBeans that I first encountered, and that was many moons ago. There is a PHP variant available, but that seemed very sluggish when I tried it and turned back to Eclipse, with which I have stuck ever since. That poor performance may have been caused by the variant of Java that was available to it, so I may give it another ago when I have the time.

OBS Studio

Here, OBS stands for Open Broadcaster Software, and that somewhat says what it does. In essence, we are talking about video recording and live-streaming. With the increasing pervasiveness of video like what once was the case with photography, it is easy to see the use case for this kind of software.

OpenOffice.org

Is this the office suite of choice for Linux? It certainly felt that way before Oracle bought Sun Microsystems and upset a few open-source developers. Now, the appearance of LibreOffice is going to make things look a little more interesting.

PlayOnLinux

This is a far more user-friendly way to run Windows software on Linux, using the WINE libraries in the background. The name seems to originate from game playing, though web browsers like Internet Explorer and Safari are available too, along with a selection of other software. For the adventurous, there also is the possibility of installing something you have yourself.

Privoxy

Here’s the description from the website:

Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data and HTTP headers, controlling access, and removing ads and other obnoxious Internet junk.

It’s available for a number of platforms, including Linux and UNIX, and offers a way of blocking ads in Google Chrome, which is how I got to hear about it. Ubuntu users can snag a copy from the usual repositories too.

Configuration is by editing text files, but the default settings have sufficient so far. Setting a browser to use it means searching through settings for the means of making it use IP address 127.0.0.1 and port 8118 for ordinary and secure HTTP connections.

Rapid Photo Downloader

When Shotwell, started to fail to download photos from ever larger memory cards, it was time to look at something else and this became the replacement. You can use it to copy images from any card reader into the directory structure of your choosing. It does nothing more than downloading, and it does it so well that it merits a mention on here.

Shotwell

This was my photo library manager of choice until its limitations when it came to handling large data volumes came to light. It is written for the GNOME desktop environment and worked well for a few years before technology overtook it. Still, it also offers limited photo editing capabilities to go with its organising skills.

UFRaw

This reader and manipulator of raw digital camera image formats acts either alone or as a plugin. It can be used via the command line or using a GUI. That makes it flexible for those times when you need things to happen without much input from yourself.

VirtualBox

All in all, this is an excellent piece of virtualisation software that makes you wonder why you’d pay for something like VMware Workstation. There is a closed source variant, but the open-source equivalent has what you’d want for personal use anyway. Windows 11 support took a while to come into place because of its TPM requirements, but that is steady these days.

VSCodium

Since the widely used VSCode is so available and appears to be open-source in nature, one does wonder why this project exists. Here is their take on that conundrum:

Microsoft’s VSCode source code is open source (MIT-licensed), but the product available for download (Visual Studio Code) is licensed under this not-FLOSS licence and contains telemetry/tracking. According to this comment from a Visual Studio Code maintainer:

When Microsoft builds Visual Studio Code, we do exactly this. They clone the VSCode repository, they lay down a customized product.json that has Microsoft-specific functionality (telemetry, gallery, logo, etc.), and then produce a build that we release under their licence.

When you clone and build from the VSCode repo, none of these endpoints are configured in the default product.json. Therefore, you generate a “clean” build, without the Microsoft customisations, which is by default licensed under the MIT licence.

The VSCodium project exists so that you don’t have to download and build from source. This project includes special build scripts that clone Microsoft’s VSCode repo, run the build commands, and upload the resulting binaries for you to GitHub releases. These binaries are licensed under the MIT licence. Telemetry is disabled.

If you want to build from source yourself, head over to Microsoft’s VSCode repo and follow their instructions. VSCodium exists to make it easier to get the latest version of MIT-licensed VS Code.

Waterfox

This is a fork of Firefox that claims to be faster and more private. From my brief test, it certainly feels faster, though I was not as able to test things on the privacy end.

  • All the views that you find expressed on here in postings and articles are mine alone and not those of any organisation with which I have any association, through work or otherwise. As regards editorial policy, whatever appears here is entirely of my own choice and not that of any other person or organisation.

  • Please note that everything you find here is copyrighted material. The content may be available to read without charge and without advertising but it is not to be reproduced without attribution. As it happens, a number of the images are sourced from stock libraries like iStockPhoto so they certainly are not for abstraction.

  • With regards to any comments left on the site, I expect them to be civil in tone of voice and reserve the right to reject any that are either inappropriate or irrelevant. Comment review is subject to automated processing as well as manual inspection but whatever is said is the sole responsibility of the individual contributor.